package com.book.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.book.core.domain.ReaderRestrictions;
import com.book.repository.ReaderRestrictionsMapper;
import com.book.service.ReaderRestrictionsService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Date;

/**
* @author hongmizfb
* @description 针对表【reader_restrictions(读者限制表)】的数据库操作Service实现
* @createDate 2025-05-08 22:54:38
*/
@Service
public class ReaderRestrictionsServiceImpl extends ServiceImpl<ReaderRestrictionsMapper, ReaderRestrictions>
    implements ReaderRestrictionsService{

    @Override
    public boolean checkCanBorrowByReaderId(Long readerId) {
       return !lambdaQuery().eq(ReaderRestrictions::getReaderId, readerId)
                .ge(ReaderRestrictions::getEndDate, LocalDateTime.now()).exists();
    }
}



